package cn.edu.scau.cmi.zhangmingxing.singleton;

public class Marsahal {
	private String name;
	private int number;
	private static Marsahal[] instance=new Marsahal[10];
	private Marsahal(String name,int n) {
		this.name=name;
		this.number=(int)(100000+Math.random()*900001);
	}
	public static Marsahal getInstance(String name) {
		for(int i=0;i<10;i++) {
			if(instance[i]!=null&&instance[i].getname().equals(name))
				return instance[i];
			if(instance[i]==null&&name!=null) {
				instance[i]=new Marsahal(name,i);
				return instance[i];
			}
		}
		return null;
	}
	public String getname() {
		return name;
	}
	public int getnum() {
		return number;
	}

}
